/*************************************************************************
 * File Name:    Pascals_Triangle.cc
 * Author:       zero91
 * Mail:         jianzhang9102@gmail.com
 * Created Time: Sat 21 Sep 2013 04:41:56 PM CST
 * 
 * Description:  
 *
 | -----------------------------------------------------------------------
 |
 | Pascal's Triangle
 | Given numRows, generate the first numRows of Pascal's triangle.
 |
 | For example, given numRows = 5,
 | Return
 |
 | [
 |     [1],
 |    [1,1],
 |   [1,2,1],
 |  [1,3,3,1],
 | [1,4,6,4,1]
 | ]
 |
 | ----------------------------------------------------------------------
 |
 ************************************************************************/

#include <iostream>
#include <vector>

using namespace std;

class Solution
{
public:
    vector<vector<int> > generate(int numRows)
    {
        if (numRows == 0) return vector<vector<int> >();
        vector<vector<int> > ans;

        ans.push_back(vector<int>(1, 1));

        for (int i = 1; i < numRows; ++i) {
            ans.push_back(vector<int>(i + 1, 0));
            ans[i][0] = ans[i - 1][0];
            ans[i][i] = ans[i - 1][i - 1];

            for (int j = 1; j < i; ++j) {
                ans[i][j] = ans[i - 1][j - 1] + ans[i - 1][j];
            }
        }

        return ans;
    }
};

int
main(int argc, char *argv[])
{
    int n;
    Solution sol;
    vector<vector<int> > ans;

    while (cin >> n) {
        ans = sol.generate(n);
        for (size_t i = 0; i < ans.size(); ++i) {
            for (size_t j = 0; j < ans[i].size(); ++j) {
                cout << ans[i][j] << " ";
            }
            cout << endl;
        }
    }
    return 0;
}
